<?php

namespace app\api\controller\zi;

use app\api\model\OrderM;
use app\common\controller\Api;
use think\Validate;

class OrderDetail extends Api
{
    protected $noNeedRight = 'index';

    public function index()
    {
        $validate = new Validate();
        if (!$validate->check(input(), [
            'order_id' => 'require|integer',
        ])) {
            $this->error($validate->getError());
        }
        $order_id = input('order_id');
        $user     = $this->auth->getUser();
        $order    = OrderM::where([
            'id'       => $order_id,
            'user_id'  => $user['id'],
            'payed_is' => OrderM::PAYED_IS_YES,
        ])->find();
        if (!$order) {
            $this->error('error order');
        }
        $order['info'] = json_decode($order['info']);
        $this->success('', [
            'order' => $order,
        ]);
    }
}
